package com.bobi.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bobi.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

/**
 * 商家进货单(BobiPurchaseOrder)实体类
 *
 * @author makejava
 * @since 2023-07-02 16:30:09
 */
@Data
@TableName("bobi_purchase_order")
@AllArgsConstructor
@NoArgsConstructor
public class PurchaseOrder extends BaseEntity {
    private static final long serialVersionUID = -24869187328627375L;

    /**
     * 进货时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date stockTime;
    /**
     * 采购员工id
     */
    private Integer staffId;
    /**
     * 进货单总价
     */
    private Object stockMoney;
    /**
     * 冗余字段，进货单的商品列表，json保存
     */


    private String orderList;
    public QueryWrapper<PurchaseOrder> initWrapper(PurchaseOrder purchaseOrder) {
        if(purchaseOrder.getId() != null || purchaseOrder.getStockTime() != null) {
            QueryWrapper<PurchaseOrder> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq(StringUtils.isNotBlank(purchaseOrder.getId()), "id", purchaseOrder.getId());
            queryWrapper.eq(StringUtils.isNotBlank((CharSequence) purchaseOrder.getStockTime()), "purchaseOrderStockTime" ,purchaseOrder.getStockTime());
            return queryWrapper;
        }
        return null;
    }




}

